package com.nage.engine;

import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class GameGraphXmlHandler extends DefaultHandler {
	
	StringBuffer buff = null;
    boolean buffering = false; 
    GameGraph graph; // holds the graph as it is built during parsing.
    
    @Override
    public void startDocument() throws SAXException {
        // Some sort of setting up work
    	graph = new GameGraph();
    } 
    
    @Override
    public void endDocument() throws SAXException {
        // Some sort of finishing up work
    } 
    
//    @Override
//    public void startElement(String namespaceURI, String localName, String qName, 
//            Attributes atts) throws SAXException {
//        if (localName.equals("level")) {
//        	graph = new GameGraph();
//        } else if (localName.equals("game_object")) {
//        	graph.add(new GameObject());
//        } else if (localName.equals("shape")) {
//        	graph.getLastObject().addComponent(new Shape(graph.getLastObject()));
//        } else if (localName.equals("physics")) {
//        	graph.getLastObject().addComponent(new Physics(graph.getLastObject()));
//        } else if (localName.equals("controllable")) {
//        	graph.getLastObject().addComponent(new Controllable(graph.getLastObject(), (Physics)graph.getLastObject().getComponent(Component.PHYSICS)));
//        } else if (localName.equals("random_movement")) {
//        	graph.getLastObject().addComponent(new RandomMovement(graph.getLastObject(), (Physics)graph.getLastObject().getComponent(Component.PHYSICS)));
//        } else if(localName.equals("virtual_button")) {
//        	graph.getLastObject().addComponent(new VirtualButton(graph.getLastObject()));
//        }
//    } 
    
    @Override
    public void characters(char ch[], int start, int length) {

    } 
    
    @Override
    public void endElement(String namespaceURI, String localName, String qName) 
    throws SAXException {

    }

	public GameGraph getGameGraph() {
		return graph;
	}
	
	
}

